package com.foreveross.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.TimeZone;

/**
 * 请求短信验证码工具类
 * 
 * @author lijianbo
 *
 */
public class VlidateDataTools {
	
	//开发者平台分配的appkey
	public static final String AppKey = "6e5b7e242c3737ee9c8361e7541e28b7";
	
	//短信secret
	public static final String AppSecret = "78c2561ae4e6";
	
	//短信模板ID
	public static final String SmsTemplateid = "6123";

	//网易云信提供的发送短信接口 详见http://dev.netease.im/docs?doc=server&#短信服务
	public static final String POST_URL = "https://api.netease.im/sms/sendtemplate.action";
	/**
	 * 生成指定位数的随机字符串
	 * @param length
	 * @return
	 */
	public static String randomString(int length) {
		String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		Random random = new Random();
		StringBuffer buf = new StringBuffer();

		for (int i = 0; i < length; i++) {
			int num = random.nextInt(62);
			buf.append(str.charAt(num));
		}
		return buf.toString();
	}
	
	public static void main(String[] args) {
		String CheckSum  =  CheckSumBuilder.getCheckSum(VlidateDataTools.AppSecret,
				VlidateDataTools.randomString(16), String.valueOf(System.currentTimeMillis()));
		System.out.println(VlidateDataTools.randomString(16));
		System.out.println(System.currentTimeMillis());
		System.out.println(CheckSum);
	}
}
